package com.picture.controller;

import com.picture.pojo.entity.Picturecategory;
import com.picture.result.Result;
import com.picture.service.PicturecategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/picture/category")
@Api(tags = "图片类别相关接口")
@Slf4j
@CrossOrigin
public class PictureCategoryController {

    @Autowired
    PicturecategoryService picturecategoryService;
    @ApiOperation("删除分类")
    @DeleteMapping("/delete")
   Result delete(int id){
        picturecategoryService.delete(id);
       return Result.success();
    }

    @ApiOperation("添加分类")
    @PostMapping("/add")
    Result add(String name){
        picturecategoryService.add(name);
        return Result.success();
    }

    @ApiOperation("查询分类")
    @GetMapping("/list")
    Result<List<Picturecategory>> query(){
        Result<List<Picturecategory>> result=picturecategoryService.categorylist();
        return result;
    }
}
